<!DOCTYPE html>
<html lang="en"xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <link rel="stylesheet" th:href="@{/css/pintuer.css}">
    <link rel="stylesheet" th:href="@{/css/admin.css}">
    <script type="application/javascript" th:src="@{/js/jquery-3.5.1.js}"></script>
    <script>
        $(document).ready(function () {
            var flag1=false;
            var flag2=false;
            var flag3=false;
            $("#oldpwd").blur(function () {
                var oldpwd=$("#oldpwd").val()
                if (oldpwd.length==0){
                    $("#oldpwdError").html("原密码不能为空!")
                    $("#oldpwdError").css('color' ,'red')
                    flag1=false
                }
                else if (oldpwd.length<6||oldpwd.length>12){
                    $("#oldpwdError").html("原密码为6-12位!")
                    $("#oldpwdError").css('color' ,'red')
                    flag1=false
                }else {
                    $("#oldpwdError").html("输入正确！")
                    $("#oldpwdError").css('color' ,'green')
                    flag1=true
                }
            })
            $("#newpwd1").blur(function () {
                var newpwd1=$("#newpwd1").val()
                if (newpwd1.length==0){
                    $("#newpwdError1").html("新密码不能为空!")
                    $("#newpwdError1").css('color' ,'red')
                    flag2=false
                }
                else if (newpwd1.length<6||newpwd1.length>12){
                    $("#newpwdError1").html("新密码为6-12位!")
                    $("#newpwdError1").css('color' ,'red')
                    flag2=false
                }else {
                    $("#newpwdError1").html("输入正确！")
                    $("#newpwdError1").css('color' ,'green')
                    flag2=true
                }
            })
            $("#newpwd").blur(function () {
                var newpwd=$("#newpwd").val()
                var newpwd1=$("#newpwd1").val()
                if (newpwd.length==0){
                    $("#newpwdError").html("不能为空")
                    $("#newpwdError").css('color' ,'red')
                    flag3=false
                }
              else  if (newpwd.length>12||newpwd.length<6){
                    $("#newpwdError").html("密码为6-12位!")
                    $("#newpwdError").css('color' ,'red')
                    flag3=false
                }
               else if (newpwd!=newpwd1){
                    $("#newpwdError").html("密码不一致!")
                    $("#newpwdError").css('color' ,'red')
                    flag3=false
                }
              else {
                    $("#newpwdError").html("输入正确！")
                    $("#newpwdError").css('color' ,'green')
                    flag3=true
                }
            })
            $("#myForm").submit(function () {
                if (flag1&&flag2&&flag3){
                    $("#newpwdError").html("")
                    $("#newpwdError1").html("")
                    $("#oldpwdError").html("")
                    $("#oldpwdError").css('color' ,'green')
                    return flag1&&flag2&&flag3;
                }else {
                    return false;
                }

            })
        })
    </script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head" id="add">
        <strong><span class="icon-pencil-square-o"></span>修改密码</strong>
    </div>
    <div class="body-content">
        <form method="post" id="myForm" class="form-x" action="/admin/updatepwd">
            <div class="form-group">
                <div class="label">
                    <label>原密码：</label>
                </div>
                <div class="field">
                    <input id="oldpwd"  type="text" class="input w50" name="oldpwd"  value="" />
                    <div class="tips" th:text="${msg}" id="oldpwdError"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>新密码：</label>
                </div>
                <div class="field">
                    <input type="password" class="input w50" name="newpwd1" id="newpwd1" value="" />
                    <div class="tips"  id="newpwdError1"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>确认密码：</label>
                </div>
                <div class="field">
                    <input type="password" class="input w50" name="newpwd" id="newpwd" value="" />
                    <div class="tips"  id="newpwdError"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <button class="button bg-main icon-check-square-o" type="submit">
                        提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
</html>